<template>
  <div>
    <el-col
      :span="24"
      class="toolbar"
      style="
        padding-bottom: 0px;
        padding-bottom: 0px;
        display: flex;
        justify-content: space-between;">
      <el-form :inline="true" :model="Withdrawalisset">
        <div>
          <div class="sub-title">{{$t('withdrawconfig.kycnotcompleted')}}</div>
        <el-form-item :label="$t('withdrawconfig.withdrawals')">
          <el-input
            v-model="Withdrawalisset.max_time"
            :placeholder="$t('withdrawconfig.entermaximum')"
            onkeyup="this.value=this.value.replace(/[^0-9]+/,'');">
                <template slot="append">USD</template>
          </el-input>
        </el-form-item>
        
        <el-form-item :label="$t('withdrawconfig.amountwithdrawal')">
          <el-input
            v-model="Withdrawalisset.max_all"
            :placeholder="$t('withdrawconfig.maximumwithdrawal')"
            onkeyup="this.value=this.value.replace(/[^0-9]+/,'');">
                <template slot="append">USD</template>
          </el-input>
        </el-form-item>
        </div>

         <div>
       <el-form-item :label="$t('withdrawconfig.dailymaximum')">
          <el-input
            v-model="Withdrawalisset.exchange_day_max"
            :placeholder="$t('withdrawconfig.maximumperday')"
            onkeyup="this.value=this.value.replace(/[^0-9]+/,'');">
                <template slot="append">USD</template>
          </el-input>
        </el-form-item> 
        
        <el-form-item :label="$t('withdrawconfig.everyday')">
          <el-input
            v-model="Withdrawalisset.withdraw_day_max"
            :placeholder="$t('withdrawconfig.withdrawalperday')"
            onkeyup="this.value=this.value.replace(/[^0-9]+/,'');">
                <template slot="append">USD</template>
          </el-input>
        </el-form-item>
        <div>
        <el-form-item v-if="diction == 'CS_V2'?false:true">
          <el-button type="primary" @click="EveryMaxaddupMax">{{$t('publicbtn.submitbtn')}}</el-button>
        </el-form-item>
        </div>
        </div>


        <div>
          <div class="sub-title">{{$t('withdrawconfig.beencompleted')}}</div>
       <el-form-item :label="$t('withdrawconfig.dailymaximum')">
          <el-input
            v-model="Withdrawalisset.kyc_exchange_day_max"
            :placeholder="$t('withdrawconfig.maximumperday')"
            onkeyup="this.value=this.value.replace(/[^0-9]+/,'');">
          
                <template slot="append">USD</template>
          </el-input>
        </el-form-item> 
        
        <el-form-item :label="$t('withdrawconfig.everyday')">
          <el-input
            v-model="Withdrawalisset.kyc_withdraw_day_max"
            :placeholder="$t('withdrawconfig.withdrawalperday')"
            onkeyup="this.value=this.value.replace(/[^0-9]+/,'');">
                <template slot="append">USD</template>
          </el-input>
        </el-form-item>

          <el-form-item :label="$t('withdrawconfig.withdrawals')">
          <el-input
            v-model="Withdrawalisset.kyc_withdraw_time_max"
            :placeholder="$t('withdrawconfig.maximumwithdrawalsperday')"
            onkeyup="this.value=this.value.replace(/[^0-9]+/,'');">
                <template slot="append">USD</template>
          </el-input>
        </el-form-item>
     
        <div>
        <el-form-item v-if="diction == 'CS_V2'?false:true">
          <el-button type="primary" @click="EveryMaxaddupMax">{{$t('publicbtn.submitbtn')}}</el-button>
        </el-form-item>
        </div>
    </div>


     <div>
          <div class="sub-title">{{$t('withdrawconfig.usertimeoutsettings')}}</div>
       <el-form-item :label="$t('withdrawconfig.timeoutetting')">
          <el-input
            v-model="overtime.timeout"
            :placeholder="$t('withdrawconfig.enterthetimeoutsetting')"
            onkeyup="this.value=this.value.replace(/[^0-9]+/,'');">
          
                <template slot="append">{{$t('field.second')}}</template>
          </el-input>
        </el-form-item> 

                 
            <el-form-item :label="$t('withdrawconfig.phoneTimeout')">
          <el-input
            v-model="overtime.phoneTimeout"
            :placeholder="$t('withdrawconfig.phoneTimeoutipt')"
            onkeyup="this.value=this.value.replace(/[^0-9]+/,'');">
          
                <template slot="append">{{$t('field.second')}}</template>
          </el-input>
        </el-form-item> 
   
   
     
        <div>
        <el-form-item v-if="diction == 'CS_V2'?false:true">
          <el-button type="primary" @click="upovertimetime">{{$t('publicbtn.submitbtn')}}</el-button>
        </el-form-item>
        </div>
    </div>

    <!-- 兌換超時時間 -->
     <div>
          <div class="sub-title">{{$t('withdrawconfig.exchangeTime')}}</div>
       <el-form-item :label="$t('withdrawconfig.exchangeTime')">
          <el-input
            v-model="Withdrawalisset.exchangeTime"
            :placeholder="$t('withdrawconfig.iptexchangeTime')"
            onkeyup="this.value=this.value.replace(/[^0-9]+/,'');">
                <template slot="append">{{$t('field.second')}}</template>
          </el-input>
        </el-form-item> 

        
   
   
     
        <div>
        <el-form-item v-if="diction == 'CS_V2'?false:true">
          <el-button type="primary" @click="EveryMaxaddupMax">{{$t('publicbtn.submitbtn')}}</el-button>
        </el-form-item>
        </div>
    </div>
  
  

 
 
      </el-form>
      <!-- <excelexport></excelexport> -->
    </el-col>
  </div>
</template>

<script>
import { getNudataRequest, postUserRequest,getUserRequestTime,postUserRequestTime } from "@/api/api";
export default {
  name: "withdraw",
  data() {
    return {
      Withdrawalisset: {
        // 未完成
        max_all: "", //累计最多
        max_time: "", //每次最多
        exchange_day_max:'', //每天兑换最多
        withdraw_day_max:'', //每天提现最多
        // 完成
        kyc_exchange_day_max:'',//.每天兑换最多(kyc)
        kyc_withdraw_day_max:'', //每天提现最多(KYC)
        kyc_withdraw_time_max:'' ,//提现每次最多
        // 兑换超时时间
        exchangeTime:''

      },
      
      overtime:{
      },
      calculate: 100000000,
    };
  },
  methods: {
    EveryMaxaddupMax() {
      var Withdrawalisset = JSON.parse(JSON.stringify(this.Withdrawalisset));
      var Withdrawalissetmsg={}
  
      Withdrawalissetmsg['maxAll'] = Withdrawalisset.max_all * this.calculate;
      Withdrawalissetmsg['maxTime'] = Withdrawalisset.max_time * this.calculate;

      Withdrawalissetmsg['exchangeDayMax'] = Withdrawalisset.exchange_day_max * this.calculate;  
      Withdrawalissetmsg['withdrawDayMax'] = Withdrawalisset.withdraw_day_max * this.calculate;

      Withdrawalissetmsg['kycExchangeDayMax'] =Withdrawalisset.kyc_exchange_day_max * this.calculate;
      Withdrawalissetmsg['kycWithdrawDayMax'] =Withdrawalisset.kyc_withdraw_day_max * this.calculate; 
      Withdrawalissetmsg['kycWithdrawTimeMax'] = Withdrawalisset.kyc_withdraw_time_max * this.calculate;
     
      Withdrawalissetmsg['exchangeTime'] = Withdrawalisset.exchangeTime;
      postUserRequest(Withdrawalissetmsg, "/updateWithdrawConfig").then((res) => {
          var data = res.data
          if(data.code==200){
            this.$message({
              message: data.message,
              type: "message"
              })
          }else{
            this.$message({
              message: data.message,
              type: "error"
              })
          }
        this.getwithdraw();

      });
    },

    
    getwithdraw(){
        getNudataRequest("/getWithdrawConfig").then((res) => {
      var data = res.data
          if(data.code==200){
            data = data.data
   
            if(data.max_time) this.Withdrawalisset.max_time = data.max_time / this.calculate;
            if(data.max_all) this.Withdrawalisset.max_all = data.max_all / this.calculate;

            if(data.exchange_day_max) this.Withdrawalisset.exchange_day_max = data.exchange_day_max / this.calculate;
            if(data.withdraw_day_max) this.Withdrawalisset.withdraw_day_max = data.withdraw_day_max / this.calculate;
           
            if(data.kyc_exchange_day_max) this.Withdrawalisset.kyc_exchange_day_max = data.kyc_exchange_day_max / this.calculate;
            if(data.kyc_withdraw_day_max) this.Withdrawalisset.kyc_withdraw_day_max = data.kyc_withdraw_day_max / this.calculate;
            if(data.kyc_withdraw_time_max) this.Withdrawalisset.kyc_withdraw_time_max = data.kyc_withdraw_time_max / this.calculate;
            if(data.exchangeTime) this.Withdrawalisset.exchangeTime = data.exchangeTime 
         
         }else{
            this.$message({
                message: data.message,
                type: "error"
              })
          }
    });
    },
          overtimetime(){
      getUserRequestTime('/getUserTimeout').then(res=>{
        let getovertime = res.data
        if(getovertime.code==200){
        this.overtime = getovertime.data
         }else{
        this.$message({
            message: getovertime.message,
            type: "error"
        })
        }
    })
    },
    upovertimetime(){
      postUserRequestTime(this.overtime,'/setUserTimeout').then(res=>{
     var updatatime = res.data
          if(updatatime.code==200){
            this.$message({
              message: updatatime.message,
              type: "message"
              })
          }else{
            this.$message({
              message: updatatime.message,
              type: "error"
              })
          }
      })
     this.overtimetime();

    },



  },

  mounted() {
  this.getwithdraw();
  this.overtimetime();
  },
};
</script>

<style>
.sub-title{
   margin-bottom:20px
}
</style>